#ifndef KEY_H_
#define KEY_H_

#include "main.h"
#include <stdbool.h>
#include <string.h>
#include "gpio.h"


#define KEY1_Pin GPIO_PIN_4
#define KEY1_Port GPIOE
#define KEY_Pin(pin_id) HAL_GPIO_ReadPin(KEY##pin_id##_Port,KEY##pin_id##_Pin)

#define KEY1_DONW 1

typedef uint16_t KeyValue_t;

typedef enum KeyStateValue{
    KEY_DOWN = 0, //shoule be 0,because the implementation of the function KeyiState()
    KEY_UP,
    KEY_LONG_PRESS,
    KEY_DOUBLECLICK,
}KeyStateValue_t;

typedef struct _Key_t
{
    // current state of key
    KeyStateValue_t State;
    int PressTime;
    int ReleaseTime;
    unsigned char KeyBuf;
} Key_t;


void KeyInit(void);
#endif /* KEY_H_ */

